using System;

namespace AvantGameMachine
{
	namespace DataManagement
	{
		public class SystemDataContainer
		{
			private StructuredData mainData;
	
			public SystemDataContainer() {
				mainData = new StructuredData();
				mainData.Name = "System";
			}
			
			internal StructuredData AddXML(string FileName,Address parentAddress,int _index) {
				StructuredData data = StructuredData.Create(FileName);
				StructuredData parent = Get(parentAddress,_index);
				parent.AddNode(data);
				return data;
			}

            internal bool DeleteAdressChildren(Address _address)
            {
                return mainData.DeleteAddressChildren(_address);
            }

			public string ToStr()
			{
				return mainData.ToString();
			}
			
			public string GetString() {
				return ToStr();
			}
			
			public StructuredData[] Get(Address _address) {
				return mainData.GetNodeFromAddress(_address);
			}

			public StructuredData Get(Address _address,int _index) {
				return mainData.GetNodeFromAddress(_address,_index);
			}
			
			public bool AddNode(StructuredData _node,Address _parentAddres,int _index) {
				Address address = _parentAddres.AddPrefix(new Address("System"));
				StructuredData parent = Get(address,_index);
				if (parent != null) {
					parent.AddNode(_node);
					return true;
				}
				return false;
			}
		}
	}
}
